/**
 * 功能：初始化
 */
// var basePath= http://127.0.0.1:80/GraduationProject
$(function () {
    clickMenus();
    ifLogin();
    
    // 退出
    $("#outLoginBtn").on("click",function(){
    	$.ajax({
    		type:"post",
    		url:basePath + "/outLogin",
    		async:true,
    		success:function(data){
    			if(data){
    				if(data.status == "200"){
    					window.location.href='login.html';
    					sessionStorage.setItem("userName","");
    				}else{
    					alert("操作失敗");
    				}
    			}
    		}
    	});
    });
});

/**
 * 功能：点击左侧菜单，主页面显示内容
 */
function clickMenus() {
    var allALink = $("#leftMenus li a.linkA");
    $("#leftMenus").on("click","a.linkA",function () {
    	$(this).css("color","#fff").parent().css({"background":"#ccc"}).siblings().css("background","").children().css("color","#000");
        var  aAttr =  $(this).attr("data-url");
        $(".LRADMS_iframe").attr("src","");
        $(".LRADMS_iframe").attr("src",aAttr);
    });

    $(".page-tabs-content").on('click','a.menuTab',function () {
        var  aTabs =  $(this).attr("data-id");
        $(".LRADMS_iframe").attr("src",aTabs);
    });
}

/**
 * 判斷是否登錄
 */
function ifLogin(){
	var username = "";
	username = sessionStorage.getItem("userName");
	console.log(username);
	if(JSON.stringify(username) =="{}" || JSON.stringify(username) == null || username == ""){
		alert("请勿非法访问！");
		window.location.href='login.html';
	}
}
























